package com.deepblue.image.maker.util;


import com.deepblue.image.maker.common.CommonResult;
import com.deepblue.image.maker.enums.BusinessEnum;

/**
 * @ClassName CommonResultUtil
 * @Description
 * @Author yangxd
 * @Date 2021/8/19 13:56
 * @Version 1.0
 **/
public class CommonResultUtil {
    /**
     * 私有构造方法
     */
    private CommonResultUtil() {
    }

    /**
     * 返回成功结果
     *
     * @return
     */
    public static <T> CommonResult<T> success() {
        return new CommonResult<>(BusinessEnum.SUCCESS.getCode(), BusinessEnum.SUCCESS.getMsg());
    }

    /**
     * 返回成功结果
     *
     * @param data
     * @param <T>
     * @return
     */
    public static <T> CommonResult<T> success(T data) {
        return new CommonResult<>(BusinessEnum.SUCCESS.getCode(), BusinessEnum.SUCCESS.getMsg(), data);
    }

    /**
     * @param businessEnum
     * @param <T>
     * @return
     */
    public static <T> CommonResult<T> fail(BusinessEnum businessEnum) {
        return new CommonResult<>(businessEnum.getCode(), businessEnum.getMsg());
    }

    /**
     * @param code
     * @param msg
     * @param <T>
     * @return
     */
    public static <T> CommonResult<T> fail(String code, String msg) {
        return new CommonResult<>(code, msg);
    }

}
